{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from docproduct.predictor import RetreiveQADoc"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "pretrained_path = 'pubmed_pmc_470k/'\n",
    "ffn_weight_file = None\n",
    "bert_ffn_weight_file = 'models/bertffn_crossentropy/bertffn'\n",
    "embedding_file = 'qa_embeddings/bertffn_crossentropy.pkl'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "doc = RetreiveQADoc(pretrained_path=pretrained_path,\n",
    "                    ffn_weight_file=None,\n",
    "                    bert_ffn_weight_file=bert_ffn_weight_file,\n",
    "                    embedding_file=embedding_file)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\r",
      "0it [00:00, ?it/s]"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\r",
      "1it [00:00,  3.42it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "i have gone through your query. you are suffering from two problems. one is nasal block and the other is sleep disturbance which may be insomnia. you can stop xaria plus (combination of montelukast and fexofenadine). instead of that you can take flutiflo-ft - fluticasone nasal spray once daily along with nasoclear nasal drops as and when required. sleep disturbance may be due to insomnia and so need sleep hygiene. stop drinking coffee or tea in the evening do regular exercises in the evening and sleep in the lateral position. try simple changes to your daytime and pre-bedtime routine. keep a regular sleep schedule go to sleep and get up at the same time each day including the weekends. set aside enough time for sleep. most people need at least seven to eight hours each night in order to feel good and be productive. make sure your bedroom is dark cool and quiet. cover electrical displays use heavy curtains or shades to block light from windows or try a sleep mask to shield your eyes. turn off your television smartphone and computer a few hours before your bedtime. the type of light these screens emit can stimulate your brain suppress the production of melatonin and interfere with your body’s internal clock. will try conservative management initially and if not improving then you may need sleep study and medications like melatonin. i want to know whether you have snoring. the probable causes:stress related sleep disorder. investigations to be done:sleep study after one month. differential diagnosis:obstructive sleep apnea (osa). probable diagnosis:insomnia. treatment plan:conservative management like sleep hygiene avoid coffee and tea and do regular exercises. regarding follow up:revert back after a month to a sleep medicine physician online. ---> <link>\n",
      "\n",
      "the eyes are affected in two ways #1 with the oxygen at night the eyes can dry out using viscous artificial tear drops will help this. #2 people with sleep apnea are more at risk for developing glaucoma an annual eye exam is important.\n",
      "\n",
      "Some studies have shown that deficiencies of antioxidants contribute to the development of chronic dry eye syndrome. Nutritional supplements containing the essential fatty acids omega-3 and omega-6 are available to help restore and maintain tear formation and eye lubrication. Check with your doctor first.\n",
      "\n",
      "burning eyes is most often due to a dry tear film unless you are exposed to chemicals or have allergies. what is your lunch diet like. avoid carbs will prevent dip in sugar during pm driving. see eyedoc2020@blogspot. com for anti-inflammatory diet or consult with us for more info.\n",
      "\n",
      "Treat anxiety = more sleep.,Artificial tears if your eyes feel dry. The only cure for tiredness is sleep. Unless you want to dabble in amphetamines/stimulants but that's just covering the issue.\n",
      "\n",
      "Treat your anxiety = more sleep \n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    }
   ],
   "source": [
    "#@markdown Type in your question (maximum of 512 words)\n",
    "inputText = 'My eyes get super dry when I sleep. Any solutions?' #@param {type:\"string\"}\n",
    "#@markdown Return top k results\n",
    "k = 5 #@param {type:\"number\"}\n",
    "#@markdown Perform similarity search by answers or questions? \n",
    "search_byI = 'answer' #@param [\"answer\", \"question\"]\n",
    "#@markdown Do you want only answers returned? \n",
    "answerOnly = True #@param [\"False\", \"True\"] {type:\"raw\"}\n",
    "\n",
    "\n",
    "advices = doc.predict( inputText , search_by=search_byI, topk=k, answer_only=answerOnly)\n",
    "\n",
    "for kj in advices:\n",
    "    print('')\n",
    "    print(kj)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python [conda env:tf]",
   "language": "python",
   "name": "conda-env-tf-py"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
